package com.mt.api.modules.service.impl;


import com.mt.api.modules.domain.BrandPayment;
import com.mt.api.modules.domain.bo.BrandPaymentAddBo;
import com.mt.api.modules.domain.vo.BrandPaymentVo;
import com.mt.api.modules.manager.IBrandPaymentManager;
import com.mt.api.modules.mapstruct.BrandPaymentMapStruct;
import com.mt.api.modules.service.IBrandPaymentService;
import com.mt.common.response.WebResponse;
import com.mt.common.response.WebResponseUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * @Author: plover
 * @Date: 2022-05-01
 * @Description:
 */
@Service
@RequiredArgsConstructor
public class BrandPaymentServiceImpl implements IBrandPaymentService {

    private final IBrandPaymentManager brandPaymentManager;
    private final BrandPaymentMapStruct brandPaymentMapStruct;


    @Override
    public WebResponse<BrandPaymentVo> getPaymentInfo() {
        BrandPayment brandPayment = brandPaymentManager.getByBrandId();
        BrandPaymentVo brandPaymentVo = brandPaymentMapStruct.toVo(brandPayment);
        return WebResponseUtils.success(brandPaymentVo);
    }

    @Override
    public WebResponse addPayment(BrandPaymentAddBo bo) {
        BrandPayment brandPayment = new BrandPayment();
        brandPayment.setId(bo.getId());
        brandPayment.setQrcodeUrl(bo.getQrcodeUrl());
        brandPayment.setType(1);
        brandPaymentManager.saveOrUpdate(brandPayment);
        return WebResponseUtils.success();
    }
}
